<?php
// +----------------------------------------------------------------------
// | Created by PHPstorm: [ JRK丶Admin ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
// +----------------------------------------------------------------------
// | SiteUrl: http://www.luckyhhy.cn
// +----------------------------------------------------------------------
// | Author: LuckyHhy <jackhhy520@qq.com>
// +----------------------------------------------------------------------
// | Date: 2020/8/10 0010
// +----------------------------------------------------------------------
// | Description:  
// +----------------------------------------------------------------------

namespace app\admin\controller\article;


use app\admin\model\article\ArticleModels;
use app\admin\validate\CheckArticleModel;
use app\common\controller\AdminBaseController;
use app\common\service\FormBuilder as Form;
use Jrk\Tree;
use think\Exception;
use think\facade\Route;
use think\Request;

class ArticleModel extends AdminBaseController
{
    protected function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->model= new ArticleModels();
    }


    /**
     * @param $id
     * @return string|\think\response\Json
     * @throws \Exception
     * @author: LuckyHhy <jackhhy520@qq.com>
     * @describe:编辑
     */
    public function edit($id){
        $info=$this->model->where("id",$id)->find()->toArray();
        if (!$info){
            return parent::failed("未查询到数据");
        }
        $f = [];
        $f[] = Form::input('name', '模型名称：',$info['name'])->required("请输入模型名称")->info("请输入模型名称");
        $f[] = Form::input('tablename', '表名：',$info['tablename'])->required("必填")->info("模型所对应的表名");
        $f[] = Form::input('index_template', '封面页模板：',$info['index_template'])->placeholder("封面页模板")->col(13)->required();
        $f[] = Form::input('list_template', '列表模板：',$info['list_template'])->placeholder("列表模板")->col(13)->required();
        $f[] = Form::input('show_template', '详情页模板：',$info['show_template'])->placeholder("详情页模板")->col(13)->required();
        $f[] = Form::input('sort', '排序：',10)->type("number")->placeholder("排序")->col(13);
        $f[] = Form::hidden("__token__", token());
        $f[] = Form::hidden("id",$info['id']);
        $form = Form::make_post_form('编辑模型', $f, Route::buildUrl('upAndAdd'));
        $this->assign(compact('form'));
        return $this->fetch('public/form-builder');

    }

}